package c.e.b.h.e.k;

import c.e.a.b.g.g;
import c.e.b.h.e.b;
import c.e.b.h.e.k.t.f;
import c.e.b.h.e.q.a;
import c.e.b.h.e.q.c.c;
import c.e.b.h.e.q.c.d;
import java.io.File;
import java.util.Collections;
import java.util.LinkedList;
import java.util.Objects;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;

/* compiled from: CrashlyticsController */
public class b0 implements Callable<g<Void>> {
    public final /* synthetic */ Boolean a;
    public final /* synthetic */ f b;

    public b0(f fVar, Boolean bool) {
        this.b = fVar;
        this.a = bool;
    }

    public Object call() throws Exception {
        b bVar = b.a;
        a aVar = t.this.m;
        Objects.requireNonNull(aVar);
        bVar.b("Checking for crash reports...");
        File[] q = t.this.q();
        File[] listFiles = t.this.m().listFiles();
        int i = 0;
        if (listFiles == null) {
            listFiles = new File[0];
        }
        LinkedList<c> linkedList = new LinkedList();
        if (q != null) {
            for (File file : q) {
                StringBuilder g = c.b.a.a.a.g("Found crash report ");
                g.append(file.getPath());
                bVar.b(g.toString());
                linkedList.add(new d(file, Collections.emptyMap()));
            }
        }
        for (File bVar2 : listFiles) {
            linkedList.add(new c.e.b.h.e.q.c.b(bVar2));
        }
        if (linkedList.isEmpty()) {
            bVar.b("No reports found.");
        }
        if (this.a.booleanValue()) {
            bVar.b("Reports are being sent.");
            boolean booleanValue = this.a.booleanValue();
            l0 l0Var = t.this.b;
            Objects.requireNonNull(l0Var);
            if (booleanValue) {
                l0Var.g.b(null);
                f fVar = this.b;
                ExecutorService executorService = t.this.e.a;
                return fVar.a.l(executorService, new a0(this, linkedList, booleanValue, executorService));
            }
            throw new IllegalStateException("An invalid data collection token was used.");
        }
        bVar.b("Reports are being deleted.");
        File[] r = t.r(t.this.l(), l.a);
        int length = r.length;
        while (i < length) {
            r[i].delete();
            i++;
        }
        Objects.requireNonNull(t.this.m);
        for (c remove : linkedList) {
            remove.remove();
        }
        t.this.s.b.b();
        t.this.w.b(null);
        return c.e.a.b.b.j.d.b(null);
    }
}
